package com.example.shuiyin.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.ResponseEntity;
import com.example.shuiyin.dto.ApiResponse;
import com.example.shuiyin.dto.UserDto;
import com.example.shuiyin.entity.User;

import java.util.HashMap;
import java.util.Map;

@RestController
public class TestApiController {
    
    @GetMapping("/api/test")
    public ResponseEntity<Map<String, Object>> apiTest() {
        Map<String, Object> response = new HashMap<>();
        response.put("message", "API测试成功");
        response.put("status", "ok");
        return ResponseEntity.ok(response);
    }
    
    @PostMapping("/api/user/test")
    public ResponseEntity<ApiResponse<UserDto>> testUserApi(@RequestBody(required = false) Map<String, String> request) {
        // 创建一个测试用户
        User testUser = new User();
        testUser.setId(1L);
        testUser.setUsername("测试用户");
        testUser.setNickname("测试昵称");
        testUser.setRole("USER");
        testUser.setEmail("test@example.com");
        
        return ResponseEntity.ok(ApiResponse.success("测试API成功", UserDto.fromEntity(testUser)));
    }
} 